#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int N = 2e5 + 10;
#define INF 0x3f3f3f3f;
typedef long long int ll;
#define close(); std::ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
//----------------------------------------------------------------------------//
int n;//a[60];
char g[60][60];
void solve()
{
    cin >> n;
    //for (int i = 1; i <= n; i++) cin >> a[i];
    string s;
    cin >> s;
    s=' '+s;

    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            if (i == j) g[i][j] = 'X';
            else if (s[i] == '1') g[i][j] = g[j][i] = '=';
            else g[i][j] = ' ';
        }
    }

    //  for (int i = 1; i <= n; i++)
    // {
    //     for (int j = 1; j <= n; j++)
    //     {
    //         cout<<g[i][j];
    //     }
    //     cout<<'\n';
    // }

    for (int i = 1; i <= n; i++)
    {
        if (s[i] == '1') continue;//初始化过了
        bool ok = true;
        for (int j = 1; j <= n; j++)//a[i]==2的时候找
        {
            if (i == j) continue;
            if (g[i][j] == ' '&&g[j][i]==' ')
            {
                ok = false;
                g[i][j] = '+';
                g[j][i] = '-';
                break;
            }
        }
        if (ok) { cout << "NO" << '\n'; return; }
    }
    cout << "YES" << '\n';
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            if (g[i][j] == ' ') g[i][j] = '=';
            cout << g[i][j];
        }
        cout << '\n';
    }


}

int main()
{
    close();
    int T;
    cin >> T;
    while (T--) solve();
    return 0;
}

//不败全为平局
//等号不影响输赢

//先把要平局的初始化好
//再扫一遍是2(赢一场的)去找他对应未初始化的队伍,且他自己也要有未初始化的一个点,一个变长+一个变成-